package com.egg.ylt.widget.imagepicker;

import com.egg.ylt.pojo.UserPhotoListEntity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created By Dlx
 * on 2019/2/25
 * 线程安全
 * imageUrl数组暂存器，取出数据即销毁，只能取一次，暂时只支持String，可按需要扩展
 */
public class ImagesDataHolder {
    private List<String> imageUrlList;
    private List<UserPhotoListEntity.ListBean> entityList;

    private ImagesDataHolder() {
    }

    public static ImagesDataHolder getInstance() {
        return InstanceHolder.INSTANCE;
    }

    private static class InstanceHolder {
        private static ImagesDataHolder INSTANCE = new ImagesDataHolder();
    }

    public void holdeImageUrlList(List<String> imageUrlList) {
        this.imageUrlList = imageUrlList;
    }

    public List<String> getImageUrlList() {
        if (imageUrlList == null) {
            return new ArrayList<>();
        }
        List<String> tempList = imageUrlList;
        imageUrlList = null;
        return tempList;
    }

    public void holdeEntityList(List<UserPhotoListEntity.ListBean> list) {
        entityList = list;
    }

    public List<UserPhotoListEntity.ListBean> getEntityList() {
        if (entityList == null) {
            return new ArrayList<>();
        }
        List<UserPhotoListEntity.ListBean> temp = entityList;
        entityList = null;
        return temp;
    }
}
